﻿package UIComponents// ActionScript file
{
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.text.TextField;

	public class PlayerLifePanel extends Sprite
	{
		private var _playerControlerFlag:DisplayObject;
		public function PlayerLifePanel():void
		{
			
		}
		
		public function setBgVisabe(arg:Boolean,txtName:String):void
		{
			this.getChildByName("playerName").visible=arg;
			this.getChildByName("playerBg").visible=arg;
			(this.getChildByName("playerName") as TextField).htmlText=txtName;
		}
		
		public function setJianTouVisable(isVisable:Boolean):void
		{
			this.getChildByName("jiantou").visible=isVisable;
		}
		
		public function setActionVisable(isVisable:Boolean):void
		{
			this.getChildByName("txt_act").visible=isVisable;
			this.getChildByName("bar_act").visible=isVisable;
		}
		public function setLifeVisable(isVisable:Boolean):void
		{
			this.getChildByName("txt_life").visible=isVisable;
			this.getChildByName("bar_life").visible=isVisable;
		}
		private var currLife:int;
		public function setLife(nowLife:int,maxLife:int):void
		{
			(this.getChildByName("txt_life") as TextField).text=nowLife+"/"+maxLife;
			this.currLife=int(100*nowLife/maxLife);
			this.setLifePercent(currLife);
		}
		
		public function setLifePercent(value:int):void
		{
			currLife=value;
			(this.getChildByName("bar_life") as MovieClip).gotoAndStop(value);
		}
		
		public function get getLifePercent():int
		{
			return currLife;
		}
		
		public function setAct(nowAct:int,maxAct:int):void
		{
			(this.getChildByName("txt_act") as TextField).text=nowAct+"/"+maxAct;
			currexp=int(100*nowAct/maxAct);
			this.setActPercent(currexp);
		}
		private var currexp:int;
		public function setActPercent(value:int):void
		{
			(this.getChildByName("bar_act") as MovieClip).gotoAndStop(value);
		}
		
		public function getActPercent():int
		{
			return currexp;
		}
		
		public function release():void
		{
			
		}

		public function get playerControlerFlag():DisplayObject
		{
			return this.getChildByName("jiantou");
		}

	}
}